const express = require('express');
const expressJoi = require("@escook/express-joi")
const multer = require("multer")
const path = require("path")

const article_handler = require("../router_handler/article")
const router =express.Router()

//创建multer的实例对象 通过dest属性指定文件存放的路径
const upload = multer({dest:path.join(__dirname,"../upload")})

//表单验证规则
const {add_article_schema} = require("../sechema/article")

//路由  这里第一次使用了两个中间件,可以直接放在路由里,因为这个需要先进性解析所以multer放在前边
router.post("/add",upload.single("cover_img"),expressJoi(add_article_schema),article_handler.addArticle)

module.exports = router